<?php

use think\migration\Migrator;
use think\migration\db\Column;

class LyWithdrawOrder extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('withdraw_order_records')
            ->addColumn('applet_id', 'integer', ['limit' => 11, 'null' => true, 'comment' => '小程序ID',"after"=>"id"])
            ->addColumn('withdraw_no', 'string', ['limit' => 100, 'null' => true, 'comment' => '提现单单号',"after"=>"applet_id"])
            ->addColumn('withdraw_amount', 'decimal', ['precision'=>10,'scale'=>'2','default' => '0.00','comment'=>'提现的金额','after' => 'withdraw_no'])
            ->addColumn('status', 'string', ['limit' => 100, 'null' => true, 'comment' => '状态',"after"=>"withdraw_amount"])
            ->addColumn('wx_withdraw_no', 'string', ['limit' => 100, 'null' => true, 'comment' => '提现单的微信侧单号',"after"=>"status"])
            ->addColumn('fail_reason', 'string', ['limit' => 255, 'null' => true, 'comment' => '提现失败的原因',"after"=>"wx_withdraw_no"])
            ->addColumn('operator_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '操作人员ID',"after" => "fail_reason"])
            ->addColumn('created_at', 'timestamp', ['default' => null,'null' => true, 'comment' => '创建时间',"after" => "operator_id"])
            ->addColumn('updated_at', 'timestamp', ['default' => null,'null' => true, 'comment' => '修改时间',"after" => "created_at"])
            ->create();

    }

    public function down()
    {
        $this->table('withdraw_order_records')
            ->drop();
    }
}
